<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>滴答办公系统-部门列表</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/media/layui/css/layui.css" media="all">
<script src="/media/js/jquery.min.js"></script>
</head>
<body>
	<div class="layui-container">
		<table class="layui-table" id="tbdata" lay-filter="tbop">
			<thead>
				<tr>
					<td>序号</td>
					<td>部门名称</td>
					<td>部门人数</td>
					<td>成立日期</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${pageUtils.recordsl}" var="dapt">
				<tr>
					<td>${dapt.id}</td>
					<td>${dapt.name}</td>
					<td>50</td>
					<td>${dapt.createtime}</td>
					<td><a class="layui-btn layui-btn-mini" href="/departupdate">编辑</a>
						<a class="layui-btn layui-btn-danger layui-btn-mini"
						lay-event="del" onclick="deleteCourse(${dapt.id},${pageUtils.pageIndex},${pageUtils.pageSize});">删除</a></td>
				</tr>
			</c:forEach>
			</tbody>
		</table>
		<div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
			<c:if test="${pageUtils.pageIndex==1}">
				<a href="#"
				   class="layui-laypage-prev layui-disabled" data-page="0">
					<i class="layui-icon">&lt;</i>
				</a>
			</c:if>
			<c:if test="${pageUtils.pageIndex!=1}">
				<a href="/departPageList/${pageUtils.pageIndex-1}/${pageUtils.pageSize}"
				   class="layui-laypage-prev" data-page="0">
					<i class="layui-icon">&lt;</i>
				</a>
			</c:if>

			<c:forEach begin="${pageUtils.numberStart}" end="${pageUtils.numberEnd}" var="num" step="1">
				<a href="/departPageList/${num}/${pageUtils.pageSize}">${num}</a>
			</c:forEach>

			<c:if test="${pageUtils.pageIndex==pageUtils.pageCount}">
				<a href="#"
				   class="layui-laypage-next layui-disabled" data-page="2">
					<i class="layui-icon">&gt;</i>
				</a>
			</c:if>

			<c:if test="${pageUtils.pageIndex!=pageUtils.pageCount}">
				<a href="/departPageList/${pageUtils.pageIndex+1}/${pageUtils.pageSize}"
				   class="layui-laypage-next " data-page="2">
					<i class="layui-icon">&gt;</i>
				</a>
			</c:if>

							<span class="layui-laypage-skip">到第
							   <input type="text" min="1" value="${pageUtils.pageIndex}" id="pageText" class="layui-input">页
								<button type="button" onclick="pageBtn()" class="layui-laypage-btn">确定</button>
							</span> 
							<span class="layui-laypage-count">共 ${pageUtils.allCount} 条  当前第${pageUtils.pageIndex}页/共${pageUtils.pageCount}页</span>
							<span class="layui-laypage-limits"> 
							    <select lay-ignore="" onchange="toPage(this)">
							        <option value="5" ${pageUtils.pageSize==5?"selected":""}>5 条/页</option>
									<option value="10" ${pageUtils.pageSize==10?"selected":""}>10 条/页</option>
									<option value="15" ${pageUtils.pageSize==15?"selected":""}>15 条/页</option>
									<option value="20" ${pageUtils.pageSize==20?"selected":""}>20 条/页</option>
							</select>
							</span>
						</div>
	</div>
<%--	<script src="/media/layui/layui.js"></script>--%>
	<script src="https://cdn.bootcdn.net/ajax/libs/layui/2.4.3/layui.all.js"></script>

	<script>
		// 分页大小调整
		function toPage(select) {
			var pageSize=$(select).val();
            location.href="/departPageList/1/"+pageSize;
		}
		//按钮跳转页面
		function pageBtn() {
			if($('#pageText').val() <= ${pageUtils.pageCount}){
				location.href="/departPageList/"+$('#pageText').val()+"/"+$("select").val();
			}else{
				layer.msg("请重新输入");
				$('#pageText').val("")
			}

		}

	</script>
	<script type="text/javascript">
	   function deleteCourse(id,ind,size){
		   layui.use('table', function() {
			   layer.confirm('是否确认删除部门?',function(index) {
				   $.getJSON("/deletedDepare",{"id":id},function (result) {
					   if (result.status == 200) {
						   layer.msg(result.message);
						   setTimeout(function () {
							   location.href ="/departPageList/"+ind+"/"+size
						   }, 600);
					   }else {
						   layer.msg(result.message);
					   }
				   });
				   // layer.msg("删除成功", {icon : 6});
				   // layer.msg("删除失败", {icon : 5});
			   });
		   });
	   }

	</script>
	
	
</body>
</html>